package org.bookr.engine.model;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Pawel Tomaszewski
 */
public class Group extends AbstractBookrEntity {
    protected String name, description;
    protected Set<Reader> readers = new HashSet<Reader>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Reader> getReaders() {
        return readers;
    }

    public void setReaders(Set<Reader> readers) {
        this.readers = readers;
    }

    public void addReader(Reader reader) {
        if(!readers.contains(reader)) {
            readers.add(reader);
            reader.setGroup(this);
        }
    }

    public void removeReader(Reader reader) {
        if(readers.contains(reader)) {
            readers.remove(reader);
            reader.setGroup(null);
        }
    }
}
